import {SystemConstant} from '@/types/emum.ts'
/**
 * 设置jwt
 * @param data
 */
export const setJwt = (data: string): void => {
  localStorage.setItem(SystemConstant.JWT, data);
};
/**
 * 获取jwt
 * @returns
 */
export const getJwt = (): string => {
  const jwt = localStorage.getItem(SystemConstant.JWT) || "";
  return jwt;
};
/**
 * 删除jwt
 */
export const removeJwt = (): void => {
  localStorage.removeItem(SystemConstant.JWT);
};
/**
 * 设置权限
 * @param data
 */
export const setPermission = (data: Array<string>): void => {
  const str = data ? JSON.stringify(data) : "";
  localStorage.setItem(SystemConstant.PERMISSION, str);
};
/**
 * 获取权限
 * @returns
 */
export const getPermission = (): Array<string> => {
  const str = localStorage.getItem(SystemConstant.PERMISSION);
  const permission = str ? JSON.parse(str) : [];
  return permission;
};
/**
 * 删除权限
 */
export const removePermission = (): void => {
  localStorage.removeItem(SystemConstant.PERMISSION);
};
/**
 * 清空缓存
 */
export const clearStorage = (): void => {
  localStorage.clear();
};
